package com.huawei.fastengine.fastview.util;

import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;

public class ParseDeeplinkUtils {
    public static String parseDeeplink(Uri uri) {
        String str = "";
        if (uri == null) {
            Log.e("FastSDKEngine", "uriData is null!");
            return "";
        }
        Object scheme = uri.getScheme();
        if (TextUtils.isEmpty(scheme)) {
            Log.e("FastSDKEngine", "uri schema is null.");
            return "";
        } else if (!scheme.equalsIgnoreCase("hap")) {
            return str;
        } else {
            Object host = uri.getHost();
            if (TextUtils.isEmpty(host) || !host.equals("app")) {
                Log.e("FastSDKEngine", "host is wrong!");
                return "";
            }
            str = uri.getPath();
            if (str == null || str.length() < 2) {
                return "";
            }
            str = str.substring(1);
            int indexOf = str.indexOf("/");
            return indexOf != -1 ? str.substring(0, indexOf) : str;
        }
    }
}
